
import { NativeModules } from 'react-native';

const { RNOss } = NativeModules;
const OSS = {
  /**
   * 通过路径上传文件到阿里云oss
   * @param fileArr [string]
   * @return {Promise<Array>} 返回为服务器路径数组，返回顺序对应上传顺序
   */
  async ossUploadFiles(fileArr) {
    let set = new Set(fileArr);
    let arr = Array.from(set);
    let result = await RNOss.uploadFileArr(arr);
    let length = fileArr.length;
    let resultArr = [];
    for (let i = 0; i < length; i++) {
      let key = fileArr[i];
      resultArr.push(result[key]);
    }
    return resultArr;
  },
  configWithHost(host){
    RNOss.configWithHost(host);
  }
}

export default OSS;
